package com.li;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;

/**
 * @author lirenchun
 */
public class EveryCharNum {

    public static void main(String[] args) {
        String str = "规避AB123";
        System.out.println(str.toLowerCase());
    }

    /**
     * 获取字符串中字符出现的最大次数
     *
     * @param str
     * @return
     */
    public static Integer getCharNum(String str) {
        int maxNum=0;
        HashMap<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < str.length(); i++) {
            if (map.containsKey(str.charAt(i))) {
                map.put(str.charAt(i), map.get(str.charAt(i)) + 1);
            } else {
                map.put(str.charAt(i), 1);
            }
        }
        Set<Entry<Character, Integer>> entrySet = map.entrySet();
        Iterator<Entry<Character, Integer>> iterator = entrySet.iterator();
        while (iterator.hasNext()) {
            Entry<Character, Integer> next = iterator.next();
            if(next.getValue()>maxNum){
                maxNum=next.getValue();
            }
        }
        return maxNum;
    }
}
